Python Game Programming By Example by Paz Alejandro Rodas de & Howse Joseph

Python Game Programming By Example by Paz Alejandro Rodas de & Howse Joseph

Author:Paz, Alejandro Rodas de & Howse, Joseph
Language: eng
Format: epub, azw3
Publisher: Packt Publishing
Published: 2015-09-27T16:00:00+00:00


Tip

Lighting and colors

When lighting is enabled, the colors are not determined by the glColor functions but by the combination of the lighting computation and the material colors set by glMaterial. To combine lighting with glColor, it is required that you enable GL_COLOR_MATERIAL first:

glEnable(GL_COLOR_MATERIAL) # ... glColor4f(r, g, b, a) # Draw polygons

Once we have initialized GLUT and enabled the GL capabilities, we complete our start() method by specifying the clear color, setting the perspective, and starting the main loop:

def start(self): # ... glClearColor(.1, .1, .1, 1) glMatrixMode(GL_PROJECTION) aspect = self.width / self.height gluPerspective(40., aspect, 1., 40.) glMatrixMode(GL_MODELVIEW) glutDisplayFunc(self.display) glutSpecialFunc(self.keyboard) glutMainLoop() def keyboard(self, key, x, y): pass



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.